1 using UnityEngine;
2 using
System.Collections;
3 using
Dialog;
4
5 public
class PickPlayButton : InputAdapter {
6
7     
public CirclesChoosed circleChoosed;
8     
public GameObject dialog;
9
10     
public void Start () {
11         gameObject.AddComponent<Actor>().addAction(
new ActionRepeat(ActionRepeat.FOREVER, new ActionSequence(
12             
new ActionRotateTo(5, 0.1f, Interpolation.sine),
13             
new ActionRotateTo(-5, 0.1f, Interpolation.sine),
14             
new ActionRotateTo(5, 0.1f, Interpolation.sine),
15             
new ActionRotateTo(-5, 0.1f, Interpolation.sine),
16             
new ActionRotateTo(5, 0.1f, Interpolation.sine),
17             
new ActionRotateTo(-5, 0.1f, Interpolation.sine),
18             
new ActionRotateTo(0, 0.1f, Interpolation.sine),
19             
new ActionDelay(2)
20             )));
21
22         dialog = (GameObject)Instantiate(dialog);
23         DialogUnity dialogUnity = dialog.GetComponent<DialogUnity>();
24         dialogUnity.setText(
"Do you want to play", "game without skills?");
25         dialogUnity.setDialogTwo(
26             
delegate()
27             {
28                 InputController.Name = InputNames.SHOP;
29                 
for (int i = 0; i < 3; i++)
30                     Attr.currentSkills[i] = -
1;
31                 Application.LoadLevel(
"GameScreen");
32             },
33             
delegate()
34             {
35                 InputController.Name = InputNames.SHOP;
36                 
//Khong lam gi ca
37             });
38          
39     }
40
41     
public void Update()
42     {
43         
if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Backspace))
44         {
45             
if (InputController.Name == InputNames.DIALOG)
46             {
47                 
if (dialog != null)
48                 {
49                     dialog.GetComponent<DialogUnity>().hideDialog();
50                     InputController.Name = InputNames.SHOP;
51                 }
52             }
53         }
54     }
55
56     
public override void OnTouchDown()
57     {
58         
if (InputController.Name != InputNames.SHOP) return;
59         
base.OnTouchDown();
60         gameObject.transform.localScale =
new Vector3(0.9f, 0.9f, gameObject.transform.localScale.z);
61         SoundManager.playButtonSound();
62     }
63
64     
public override void OnCheckUp()
65     {
66         
if (InputController.Name != InputNames.SHOP) return;
67         
base.OnCheckUp();
68         gameObject.transform.localScale =
new Vector3(1, 1, gameObject.transform.localScale.z);
69     }
70
71     
public override void OnTouchUp()
72     {
73         
if (InputController.Name != InputNames.SHOP) return;
74         
base.OnTouchUp();
75
76         
int[] skillChoosed = circleChoosed.getSkillChoosed();
77         
bool hasSkill = false;
78         
for (int i = 0; i < skillChoosed.Length; i++)
79         {
80             
if (skillChoosed[i] > -1)
81             {
82                 hasSkill =
true;
83                 
break;
84             }
85         }
86
87         Attr.currentSkills = skillChoosed;
88         
if (hasSkill)
89         {
90             SoundManager.stopMusic();
91             Application.LoadLevel(
"GameScreen");
92         }
93         
else
94         {
95             dialog.GetComponent<DialogUnity>().showDialog();
96             InputController.Name = InputNames.DIALOG;
97         }
98     }
99 }


Khong lam gi ca




Trò chơi đua xe động vật trong UNITY Engine 114.671 lượt xem

Gõ tìm kiếm nhanh...